<script>
	export default {
		onLaunch: function() {
			console.log('App Launch')
			wx.login({
				success: (res) => {
					console.log(res);
					console.log(res.code);
					if (res.code) { //微信登录成功 已拿到code  
						uni.request({
							url: this.$api + "/login/index",
							method: "POST",
							data: {
								code: res.code
							},
							success: res => {
								console.log(res)
								var e = res.data
								console.log(e)
								if (e.code == 200) {
									uni.setStorageSync('token', e.data.token);
									uni.showToast({
										title: '登录成功',
										icon: 'none'
									});
								} else {
									uni.showToast({
										title: '登录失败'
									});
								}
							}
						})
					} else {
						console.log('登录失败！' + res.errMsg)
					}
				}
			})
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
</style>
